import { ElButton, ElInput, ElRadio, ElRadioGroup } from 'element-plus';

// 使用 h 函数渲染组件
export const _components = (data: any, field: any) => {
  const { component, values, ...attrs } = data;
  switch (component) {
    case 'ElButton': {
      return (
        <ElButton
          onClick={() => field.onChange('')}
          size="large"
          style={{
            display:
              values && values.gender && values.gender === '男'
                ? 'none'
                : 'inline-block',
          }}
          type="primary"
        >
          {field.modelValue}
        </ElButton>
      );
    }

    case 'ElInput': {
      return <ElInput {...field} {...attrs.componentProps} />;
    }

    case 'ElRadio': {
      return (
        <ElRadioGroup {...field} {...attrs.componentProps}>
          {attrs.componentProps.options.map((item: any) => (
            <ElRadio key={item.value} value={item.value}>
              {item.label}
            </ElRadio>
          ))}
        </ElRadioGroup>
      );
    }
  }
};
